Skip to content

fix: Allow loki.source.file to read renaming lines of a deleted file before it tries to re open a new one #5270

Merged
kalleep merged 3 commits intomainfrom
kalleep/fix-loki-source-file-buffered-lines
Jan 16, 2026
Merged

fix: Allow loki.source.file to read renaming lines of a deleted file before it tries to re open a new one #5270
kalleep merged 3 commits intomainfrom
kalleep/fix-loki-source-file-buffered-lines

Conversation

@kalleep
Copy link
Contributor

@kalleep kalleep commented Jan 15, 2026

Pull Request Details

When we detect that a file is deleted we drain anything left from the opened fd. But then we tried to reopen then new file created.

I am working better integration tests for this component and discovered that we could miss these buffered lines if the file was deleted and no new file would was created. What we want to do is to be able to consume these even if a new file never is created and the target disappear eventually.

So before this pr if a file was deleted and we successfully drained the rest of the file these would not be returned before the new filed appeared because we would be stuck waiting on this new file.

It is safe to return here because we will return buffered lines and then get the same event again.

The test I added fails on main.

Issue(s) fixed by this Pull Request

Notes to the Reviewer

PR Checklist

  • Documentation added
  • Tests updated
  • Config converters updated

@kalleep kalleep requested a review from a team as a code owner January 15, 2026 14:17
@kalleep kalleep changed the title fix: loki.sourice.file now return buffered lines before reopening new file fix: Allow loki.source.file to read renaming lines of a deleted file before it tries to re open a new one Jan 15, 2026
@kalleep kalleep merged commit f8b1de8 into main Jan 16, 2026
46 of 48 checks passed
@kalleep kalleep deleted the kalleep/fix-loki-source-file-buffered-lines branch January 16, 2026 07:59
@grafana-alloybot grafana-alloybot bot mentioned this pull request Jan 16, 2026
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 31, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants